home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 55375 / 55375.xpi / components / btClientService.js next >
Text File  |  2009-11-15  |  3KB  |  87 lines

  1. /* If you are upgrading from toolbar to boom, use a new CLSID and change 1 to 2 */
  2. const BT_SHORTNAME = "coolhandnuke";
  3. const BT_CLSID      = Components.ID('{e2fd51c9-33ff-4409-8e5f-250f9c583644}');
  4.  
  5. const BT_CONTRACTID = "@mozilla.org/bt-service-" + BT_SHORTNAME + ";1";
  6.  
  7. const Cc = Components.classes;
  8. const Ci = Components.interfaces;
  9. const Cr = Components.results;
  10.  
  11. const gPrefService = Cc["@mozilla.org/preferences-service;1"].getService(Ci.nsIPrefService);
  12. const gPrefBranch = gPrefService.getBranch(null).QueryInterface(Ci.nsIPrefBranch2);
  13. const gObserver = Cc['@mozilla.org/observer-service;1'].getService(Ci.nsIObserverService);
  14. const gScriptLoader = Cc["@mozilla.org/moz/jssubscript-loader;1"].getService(Ci.mozIJSSubScriptLoader);
  15. const gConsoleService = Cc["@mozilla.org/consoleservice;1"].getService(Ci.nsIConsoleService);   
  16.  
  17. Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
  18.  
  19. function BTHandler() {
  20. }
  21.  
  22. BTHandler.prototype = {
  23.   brandObject: null,
  24.   observe: function(aSubject, aTopic, aData) {
  25.     switch(aTopic) {
  26.       case "app-startup":
  27.         gObserver.addObserver(this,"xpcom-shutdown",false);
  28.         gObserver.addObserver(this,"profile-after-change",false);
  29.         gObserver.addObserver(this,"profile-before-change",false);
  30.         gObserver.addObserver(this,"final-ui-startup",false);
  31.         /* Use our location to find out where to get btClient.js */
  32.         var file = __LOCATION__.parent.parent;
  33.         file.append("chrome");
  34.         file.append("chromeFiles");
  35.         file.append("content");
  36.         file.append("btServiceUtilities.js");
  37.         var filepath = Cc["@mozilla.org/network/io-service;1"]
  38.                                  .getService(Ci.nsIIOService)
  39.                                  .newFileURI(file).spec;
  40.         gScriptLoader.loadSubScript(filepath, this);
  41.         file.leafName = "btClient.js";
  42.         var filepath = Cc["@mozilla.org/network/io-service;1"]
  43.                                  .getService(Ci.nsIIOService)
  44.                                  .newFileURI(file).spec;
  45.         gScriptLoader.loadSubScript(filepath);
  46.         /* Use the first client in the Brandthunder.clients array */
  47.         for (client in BrandThunder.clients) {
  48.           this.brandObject = BrandThunder.clients[client];
  49.           break;
  50.         }
  51.         break;
  52.       case "xpcom-shutdown":
  53.         gObserver.removeObserver(this,"xpcom-shutdown");
  54.         gObserver.removeObserver(this,"profile-after-change");
  55.         gObserver.removeObserver(this,"profile-before-change");
  56.         gObserver.removeObserver(this,"final-ui-startup");
  57.         break;
  58.       case "profile-after-change":
  59.         this.profileAfterChange(this.brandObject);
  60.         this.firstRun(this.brandObject);
  61.         break;
  62.       case "profile-before-change":
  63.         this.profileBeforeChange(this.brandObject);
  64.         break;
  65.       case "final-ui-startup":
  66.         this.finalUIStartup(this.brandObject);
  67.         break;
  68.     }
  69.   },
  70.   log: function(string) {
  71.     gConsoleService.logStringMessage(string);
  72.   },
  73.  
  74.   classDescription: "BT Service " + BT_SHORTNAME,
  75.   contractID: BT_CONTRACTID,
  76.   classID: BT_CLSID,
  77.   QueryInterface: XPCOMUtils.generateQI([Ci.nsIObserver]),
  78.   _xpcom_categories: [{
  79.     category: "app-startup",
  80.     service: true
  81.   }]
  82. }
  83.  
  84. function NSGetModule(compMgr, fileSpec) {
  85.   return XPCOMUtils.generateModule([BTHandler]);
  86. }
  87.